#include<cstdio>
#include<cstring>
using namespace std;
const int MAX = 1000;

void getNext(int next[], char s[]){
	int k = -1, len = strlen(s);
	next[0] = -1;
	for(int i=0;i<len-1;){
		if(k == -1 || s[i] == s[k]){
			k++;
			i++;
			next[i] = k; 
		}else{
			k = next[k];
		}
	}
}

int kmp(char s[], char t[]){
	int next[MAX], lens = strlen(s), lent = strlen(t), i = 0, j = 0;
	getNext(next, t);
	while(i < lens && j < lent){
		if(j == -1 || s[i] == t[j]){
			i++;
			j++;
		}else{
			j = next[j];
		}
	}
	if(j >= lent){
		return i - lent;
	}else{
		return -1;
	}
}

int main(){
	char s[MAX], t[MAX];
	scanf("%s %s", s, t);
	printf("%d\n", kmp(s, t));
	return 0;
}
